﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AAA.Meta.Trade;

namespace AAA.Trade.SignalCatcher
{
    public class SignalCatcher
    {
        private event FilledOrderEvent _filledOrderEvent;
        private event ActiveOrderEvent _activeOrderEvent;
        private event CanceledOrderEvent _canceledOrderEvent;
        private event OpenPositionEvent _openPositionEvent;
        private Dictionary<string, string> _dicConfig;

        public SignalCatcher()
        {
            _dicConfig = new Dictionary<string, string>();
        }

        public FilledOrderEvent OnFilledOrderEvent
        {
            get { return _filledOrderEvent; }
            set { _filledOrderEvent = value; }
        }

        public ActiveOrderEvent OnActiveOrderEvent
        {
            get { return _activeOrderEvent; }
            set { _activeOrderEvent = value; }
        }

        public CanceledOrderEvent OnCanceledOrderEvent
        {
            get { return _canceledOrderEvent; }
            set { _canceledOrderEvent = value; }
        }

        public OpenPositionEvent OnOpenPositionEvent
        {
            get { return _openPositionEvent; }
            set { _openPositionEvent = value; }
        }

        public void SetParameter(string strName, string strValue)
        {
            if (_dicConfig.ContainsKey(strName))
                _dicConfig[strName] = strValue;
            else
                _dicConfig.Add(strName, strValue);
        }

        public string GetParameter(string strName)
        {
            return _dicConfig.ContainsKey(strName)
                    ? _dicConfig[strName]
                    : null;
        }
    }
}
